using System;
using System.Collections.Generic;
using System.Text;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Graphics.Particle;

using FlatRedBall.Math.Geometry;
using FlatRedBall.Math.Splines;
using BitmapFont = FlatRedBall.Graphics.BitmapFont;
using Cursor = FlatRedBall.Gui.Cursor;
using GuiManager = FlatRedBall.Gui.GuiManager;

#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;


#endif

namespace MP3.Entities
{
	public partial class Puck
	{
        
        public int deathCount { set; get; }
        public FlatRedBall.Graphics.Text Label;

		private void CustomInitialize()
		{
            Tex.Texture = FlatRedBallServices.Load<Texture2D>("/Resources/Textures/Ball.png");
            Label = new FlatRedBall.Graphics.Text();
            HealthBar.ScaleY = .1f;
            HealthBar.Texture = FlatRedBallServices.Load<Texture2D>("/Resources/Textures/GreenBar.png");
            HealthBar.ParentRotationChangesRotation = false;
            HealthBar.ParentRotationChangesPosition = false;
		}

		private void CustomActivity()
		{
            YVelocity += Gravity;   // update gravity
            RotationZ = Position.X * Gravity * 2.2f / BodyRadius;   // update rotation
            HealthBar.RelativePosition = new Vector3(0, BodyRadius + .4f, 0);   // update healthbar
            updateHealthBar();  
            
		}

		private void CustomDestroy()
		{
            
		}

        private static void CustomLoadStaticContent(string contentManagerName)
        {


        }
        
       
        public void CountMyDeath()
        {
            if (Velocity.Length() < 2.0)
                deathCount--;
            else
                deathCount = 200;
        }

        // updates the healthbar accoridng to deathcoutner
        private void updateHealthBar()
        {
            HealthBar.ScaleX = ((Body.Radius) * (deathCount / 200f));
        }
	}
}
